<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Management/Manage.Master" %>
<%@ Import Namespace="CSI.Directory.Core.Model"%>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Edit Listing
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">
    
    
    $(document).ready(function() {

        $("a").removeClass("current");
        $("#listings").addClass("current");
        var e = jQuery.Event("click");
        $("#listings").trigger(e);
        $("#edit-listing").addClass("current");
        $("#state").val('<%=((Listing)ViewData["Listing"]).State %>');
        

    });
</script>
    <h5><a href="/Management/EditAssociations/<%=((Listing)ViewData["Listing"]).Id %>">Manage Attributes</a></h5>
    <div class="content-box">
        <!-- Start Content Box -->
        <div class="content-box-header">
            <h3>
                Edit Listing</h3>
            
            <div class="clear">
            </div>
        </div>
        <!-- End .content-box-header -->
        <div class="content-box-content">
            <div class="tab-content default-tab" id="tab1">
    <h2></h2> 
            <form name="listingform" method="post" action="/Management/EditListing" onsubmit="return validate()"
            enctype="multipart/form-data">
            <fieldset>
                <!-- Set class to "column-left" or "column-right" on fieldsets to divide the form into columns -->
                <p>
                    <label> Company</label>
                    <input type="text" size="60" value="<%=((Listing)ViewData["Listing"]).Name %>" name="title" /><span
                        style="color: red">*</span>
                </p>
                <p>
                    <label>
                        Contact Name</label>
                    <input type="text" maxlength="100" value="<%=((Listing)ViewData["Listing"]).Contact %>"
                        name="contact" /><span style="color: red">*</span>
                </p>
                <p>
                    <label>
                        E-mail</label>
                    <input type="text" maxlength="50" value="<%=((Listing)ViewData["Listing"]).Email %>"
                        name="email" />
                </p>
                <p>
                    <label>URL:
                    </label>
                    
                    <input type="text" maxlength="255" value="<%=((Listing)ViewData["Listing"]).Url %>"
                        name="url" style="width: 425px;" /><span style="color: red">*</span>
                </p>
                <p>
                    <label>Phone:
                    </label>
                    
                    <input type="text" value="<%=((Listing)ViewData["Listing"]).Phone %>" name="phone" />
                </p>
                <p>
                    <label>Address Line1:
                    </label>
                    
                    <input type="text" maxlength="50" value="<%=((Listing)ViewData["Listing"]).AddressLine1 %>"
                        name="address" /><span style="color: red">*</span> <span>Street Address, P.O. box
                    </span>
                </p>
                <p>
                    <label>Address Line2:
                    </label>
                    
                    <input type="text" maxlength="50" value="<%=((Listing)ViewData["Listing"]).AddressLine2 %>"
                        name="address2" />
                    <span>Apartment, suite, unit, building, floor, etc. </span>
                </p>
                <p>
                    <label>City:
                    </label>
                    
                    <input type="text" maxlength="50" value="<%=((Listing)ViewData["Listing"]).City %>"
                        name="city" /><span style="color: red">*</span>
                </p>
                <p>
                    <label>State:
                    </label>
                    
                    <select name="state" id="state">
                        <option value="AL">AL</option>
                        <option value="AK">AK</option>
                        <option value="AZ">AZ</option>
                        <option value="AR">AR</option>
                        <option value="CA">CA</option>
                        <option value="CO">CO</option>
                        <option value="CT">CT</option>
                        <option value="DE">DE</option>
                        <option value="DC">DC</option>
                        <option value="FL">FL</option>
                        <option value="GA">GA</option>
                        <option value="HI">HI</option>
                        <option value="ID">ID</option>
                        <option value="IL">IL</option>
                        <option value="IN">IN</option>
                        <option value="IA">IA</option>
                        <option value="KS">KS</option>
                        <option value="KY">KY</option>
                        <option value="LA">LA</option>
                        <option value="ME">ME</option>
                        <option value="MD">MD</option>
                        <option value="MA">MA</option>
                        <option value="MI">MI</option>
                        <option value="MN">MN</option>
                        <option value="MS">MS</option>
                        <option value="MO">MO</option>
                        <option value="MT">MT</option>
                        <option value="NE">NE</option>
                        <option value="NV">NV</option>
                        <option value="NH">NH</option>
                        <option value="NJ">NJ</option>
                        <option value="NM">NM</option>
                        <option value="NY">NY</option>
                        <option value="NC">NC</option>
                        <option value="ND">ND</option>
                        <option value="OH">OH</option>
                        <option value="OK">OK</option>
                        <option value="OR">OR</option>
                        <option value="PA">PA</option>
                        <option value="RI">RI</option>
                        <option value="SC">SC</option>
                        <option value="SD">SD</option>
                        <option value="TN">TN</option>
                        <option value="TX">TX</option>
                        <option value="UT">UT</option>
                        <option value="VT">VT</option>
                        <option value="VA">VA</option>
                        <option value="WA">WA</option>
                        <option value="WV">WV</option>
                        <option value="WI">WI</option>
                        <option value="WY">WY</option>
                    </select><span style="color: red">*</span>
                </p>
                <p>
                    <label>Zipcode:
                    </label>
                    
                    <input type="text" maxlength="10" value="<%=((Listing)ViewData["Listing"]).Zip %>"
                        name="zipcode" /><span style="color: red">*</span>
                </p>
                <p>
                    <label>Image
                    </label>
                    
                    <input name="image" size="50" type="file">
                    
                    <br />
                    <% if(((Listing)ViewData["Listing"]).Image != ""){ %>
                        <img src="/Assets/Uploads/<%=((Listing)ViewData["Listing"]).Image %>" />
                    <%} %>
                    
                </p>
                <p>
                    <label>Description
                    </label>
                    
                    <textarea name="description" rows="10" cols="60">
                        <%=((Listing)ViewData["Listing"]).Description %>
                    </textarea>
                    
                </p>
                <p>
                    <label>Tags
                    </label>
                    
                    <input name="keywords" value="<%=((Listing)ViewData["Listing"]).Keywords %>" size="40" />
                </p>
            </fieldset>
            
    
             <input type="button" onclick="return DoAjaxSubmit(this);" value="Save" class="button" />
             <div id="results"></div>
    <input type="hidden" value="<%=((Listing)ViewData["Listing"]).Id %>" name="id" />
    </form>
    </div>
        </div>
    </div>
      
     <script type="text/javascript">
    
        function DoAjaxSubmit(btnClicked) {
            var form = $(btnClicked).parents('form');
                $("#results").html("");
                $.ajax({
                    type: "POST",
                    url: form.attr('action'), //'<%=ResolveUrl("~/register/go") %>',
                    data: form.serialize(),
                    error: function(xhr, status, error) {
                    },
                    success: function(response) {
                        if (response != null) {
                            if (!response.Successful) {
                                $("#results").html("An error occurred: " + response.Exception).addClass("red");
                                return false;
                            }
                            else {
                                $("#results").html("Listing updated").addClass("green");
                                
                            }
                        }
                      }
                    
                });
            
            return false;
        }
    </script>
      

</asp:Content>


